#@layout() #define main()
<div class="xp-layout">
	<form id="deptForm" action="xpDepartment/edit" method="post" class="layui-form layui-form-pane">
		<input type="hidden" name="dept.id" value="#(dept.id??)" />
		<div class="layui-form-item">
			<div class="layui-col-md6 layui-col-sm6 xp-col-padding5">
				<label class="layui-form-label">部门名称</label>
				<div class="layui-input-block">
					<input type="text" name="dept.name" value="#(dept.name??)" lay-verify="required" maxlength="50" autocomplete="off" placeholder="请输入部门名称" class="layui-input">
				</div>
			</div>
			<div class="layui-col-md6 layui-col-sm6 xp-col-padding5">
				<label class="layui-form-label">编号</label>
				<div class="layui-input-block">
					<input type="text" name="dept.bh" value="#(dept.bh??)" lay-verify="required" autocomplete="off" placeholder="请输入部门编号" class="layui-input xp-disable-btn" readonly="readonly">
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-col-md6 layui-col-sm6 xp-col-padding5">
				<label class="layui-form-label">联系人</label>
				<div class="layui-input-block ">
					<input type="text" name="dept.lxrName" value="#(dept.lxrName??)" lay-verify="required" autocomplete="off" maxlength="20" placeholder="请输入联系人姓名" class="layui-input">
				</div>
			</div>
			<div class="layui-col-md6 layui-col-sm6 xp-col-padding5">
				<label class="layui-form-label">电话</label>
				<div class="layui-input-block">
					<input type="text" name="dept.phone" value="#(dept.phone??)" lay-verify="required" autocomplete="off" maxlength="20" placeholder="请输入手机号" class="layui-input">
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-col-md6 layui-col-sm6 xp-col-padding5">
				<label class="layui-form-label">行政区化</label>
				<div class="layui-input-block">
					<select name="dept.xzqh" lay-filter="changexzqh"> #@option(xzqhList,"dmz","dmsm",dept.xzqh??,false)
					</select>
				</div>
			</div>
			#if(bEdit && !bSelf)
			<div class="layui-col-md6 layui-col-sm6 xp-col-padding5">
				<label class="layui-form-label">权限</label>
				<div class="layui-input-block ">
					<a onclick="right('#(dept.id??)');" class="layui-btn layui-btn-primary">设置部门权限</a>
				</div>
			</div>
			#end
		</div>
		<div class="layui-form-item">
			<div style="text-align: center;">
				<button class="layui-btn" lay-submit="" lay-filter="go">立即提交</button>
			</div>
		</div>
	</form>
	<script type="text/javascript">
		layui.use([ 'form', 'laydate' ], function() {
			var form = layui.form, layer = layui.layer, laydate = layui.laydate;

			//监听指定开关
			form.on('switch(switchState)', function(data) {
				$("#state").val(this.checked ? '1' : '0');
			});

			//监听提交
			form.on('submit(go)', function(data) {
				var url = $('#deptForm').attr('action');
				$.post(url, data.field, function(res) {
					if (res.result == 1) {
						layer.msg(res.msg, {
							icon : 1,
							time : 1000
						}, function() {
							var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
							parent.layer.close(index); //再执行关闭  
							parent.reloadList();//重新reload列表
						});
					} else {
						layer.msg(res.msg, {
							icon : 5
						});
					}
				});
				return false;
			});
		});
		function right(ID) {
			layer.open({
				type : 2,
				title : '编辑部门权限',
				area : [ '60%', '60%' ],
				shade : 0,
				maxmin : true,
				id : 'deptRight_iframe',
				content : 'xpDepartment/right_ui?ID=' + ID,
				btn : [ '提交', '关闭' ],
				yes : function(index, layero) {
					var iframeWin = window[layero.find('iframe')[0]['name']];
					iframeWin.saveRight();
				},
				btn2 : function(index, layero) {
				},
				zIndex : layer.zIndex,
				success : function(layero) {
					layer.setTop(layero);
				}
			});
		}
	</script>
</div>
#end
